#include <bits/stdc++.h>
#include <execution>
using namespace std;
using ll = int64_t;

const ll maxn{3000+5};
ll n,m;
string tmp,a[maxn],tmp1;
multiset<string> b;

int main(){
    iostream::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>n>>m;
    for(ll i{1};i<=n;i++){
        cin>>tmp;
        tmp1=tmp;
        sort(execution::par,tmp1.begin(),tmp1.end());
        a[i]=std::move(tmp1);
        sort(execution::par,tmp.begin(),tmp.end(),greater());
        b.emplace(std::move(tmp));
    }

    for(ll i{1};i<=n;i++){
        //第i个不是b中最小的
        if(auto it=b.lower_bound(a[i]);it!=b.begin()){
            cout<<'0';
        }else{
            cout<<'1';
        }
    }
    cout<<'\n';
    
}